*pingpong :csrt;
*soccer :csrt;
*car_racing :csrt;
*mucche :csrt;
*aereoplani :mosse;
*tennis :mosse.
IoU Precision e Recall
In object detection problems, IoU evaluates the overlap between ground-truth mask (gt) and the predicted mask (pd). It is calculated as the area of intersection between gt and pd divided by the area of the union of the two, that is,
Diagrammatically, IoU is defined as:
We can, therefore, redefine TP (correct detection) as a detection for which IoU≥ α and FP (invalid detection) with IoU< α. FN is a ground-truth missed by the model.
For example, at IoU threshold, α = 0.5 (or 50%), we can define TP, FP and FN as shown in the Fig 4 below.
Note: If we raise IoU threshold above 0.86, the first instance will be a FP and if we lower IoU threshold below 0.24, the second instance becomes TP.
###Precision and Recall
As started earlier TN are not used in object detection problems and therefore one as to avoid metrics based on this confusion matrix component such as True Negative Rate (TNR), False Positive Rate (FPR), Negative Predictive Value (NPC) and Receiver Operating Characteristic (ROC) curve. Instead, the evaluation of object detection models based on Precision (P) and Recall (R) which are defined as
Precision is the ability of a classifier to identify relevant objects only. It is the proportion of true positive detections.
Recall, on the other hand, measures the ability of the model to find all relevant cases (that is, all ground-truths) — the proportion of true positives detected among all ground-truths.
A good model is a model that can identify most ground-truth objects (high recall) while only finding the relevant objects (high precision) often. A perfect model is the one with FN=0 (recall=1) and FP=0 (precision=1). The former is usually the objective, the latter often unattainable.
The precision-recall (PR) curve is a plot of precision as a function of recall. It shows trade-off between the two metrics for varying confidence values for the model detections. If the FP is low, the precision is high but more object instances may be missed yielding high FN — low recall. Conversely, if one accepts more positives by lowering IoU threshold, α, the recall will increase but false positives may also increase, decreasing the precision score. For a good model, both precision and recall should remain high even if the confidence threshold varies.
passo praticamente [ Ax, Ay, Bx, By ] per ogni rettangolo, dove A è il punto in alto a sinistra e B il punto in basso a destra
calcolo_area<-function(coord_1){
return((coord_1[3]-coord_1[1])*(coord_1[4]-coord_1[2]))
}
intersezione_area <- function(coord_1, coord_2) {
dx <-min(coord_1[3],coord_2[3])- max(coord_1[1],coord_2[1])
dy<-min(coord_1[4],coord_2[4])- max(coord_1[2],coord_2[2])
if (dx>=0 & dy>=0){
return(dx*dy)}
else{ return(0)}
}
unione_area <-function(coord_1,coord_2){
return(calcolo_area(coord_1)+calcolo_area(coord_2)-intersezione_area(coord_1,coord_2))
}
IOU <- function(coord_1,coord_2){
if(unione_area(coord_1,coord_2)!=0){
return(intersezione_area(coord_1,coord_2)/unione_area(coord_1,coord_2))
}else
return(0)}
precision = tp/tp+fp recall = tp/tp+fn
If IoU < 0.5. This means that we are drawing a bounding box around an object but classifying it as another object. Suppose that we are detecting dogs and cats in an image. When the algorithm detects a dog but misclassifies it as a cat, then it is the case false positive.
If IoU >= 0.5. This means that there is an object and we have detected it.
This is the case when the algorithm does not detect anything when it should be detecting. For example, there is a dog in the image but the algorithm does not draw any bounding box around it.
https://plotly.com/ggplot2/animations/ https://learnopencv.com/object-tracking-using-opencv-cpp-python/ https://www.datanovia.com/en/blog/ggplot-examples-best-reference/ https://ggplot2.tidyverse.org/reference/geom_point.html https://machinelearning4developers.blogspot.com/2021/09/computer-vision.html https://debuggercafe.com/evaluation-metrics-for-object-detection/